#/user/bin/bash
set -e
# 获取远程仓库的最新信息
git fetch

# 获取当前分支名称
current_branch=$(git rev-parse --abbrev-ref HEAD)

# 比较本地分支与远程分支的差异
if [ $(git rev-parse HEAD) = $(git rev-parse @{u}) ]; then
    echo "本地分支 $current_branch 已经是最新的，无需pull"
else
    echo "本地分支 $current_branch 不是最新的，正在执行git pull..."
    git pull
    npm install --legacy-peer-deps  -C ../ui/ &&  npm run build -C ../ui/
    docker build . -t 192.168.2.201:5000/tafei-things
    docker push 192.168.2.201:5000/tafei-things
    #获取当前日期
    date=$(date +%Y%m%d)
    docker tag  192.168.2.201:5000/tafei-things 192.168.2.201:5000/tafei-things:$date
    docker push 192.168.2.201:5000/tafei-things:$date   
fi



#dotnet publish -c Release -r linux-x64 --self-contained true /p:PublishSingleFile=true
